<?php 
class adviceComponents extends sfComponents
  {
	  public function executeAdvice(sfWebRequest $request)
      {
		  $module = $this->getRequest()->getParameter('module');
		  	
		  if($this->getUser()->isAuthenticated())
			$userConnect = "0";
		  else
		  	$userConnect = "1";
				
		  $q = Doctrine_Query::create()
	 		->from('advices n')
			->where('n.condi_page like "%'.$module.'%"')
			->andWhere('(n.condi_connect = "2" OR n.condi_connect = "'.$userConnect.'")')
			->andWhere("n.online = ?","1")
			->orderBy('rand()')
			->limit('1');
			
		 $this->advice = $q->fetchOne();
		 		  
	  }
  }